package com.wc.alorithm_luogu.P8825;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/11/10 15:29
 * @description
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Test t = new Test();
        t.dfs(0, 0, n, k);
        System.out.println(ans% (1000000007L));
    }

    static long ans = 0;

    public void dfs(int curFloor, long sum, int n, int k) {
        if (curFloor == n) {
            if (sum % k == 0) {
                ans++;
            }
            return;
        }

        for (int i = 1; i <= 6; i++) {
            dfs(curFloor + 1, sum * 10 + i, n, k);
        }
    }
}
